package com.zxlspace.collection2;

/**
 * 泛型
 */
public class ArrayRowType {
    public static void main(String[] args) {
        Integer[] integers = new Integer[4];

//        StudentA<?>[] stu = new StudentA<String>[10]; 没有泛型数组
        StudentA<?>[] stu = new StudentA[10];
        MyArrayList<String>  arrayList = new MyArrayList<>();
        arrayList.add(0, "aa");
        arrayList.add(1, "bb");
        String str = arrayList.get(1);
        System.out.println(str);
    }
}

class  MyArrayList<E> {
//    E[] cap = new E[10]; 没有泛型数组
    Object[] elementData = new Object[10];

    public void add(int index,E e) {
        elementData[index] = e;
    }

    public E[] getAll() {
        return (E[]) elementData;
    }

    public E get(int index) {
        return (E) elementData[index];
    }
}
